package com.music.action.listen;

import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.music.action.BaseAction;
import com.music.action.BaseKey;
import com.music.common.ParamUtil;
import com.music.domain.Music;
import com.music.listen.service.ListenService;

/**
 * 推荐音乐，只有登录的用户才有的功能
 * @author LFSenior
 *
 */
public class ListenAction extends BaseAction{
	@Autowired
	ListenService listenService;
	
	@Action(value="listen",results={@Result(name="listen",location="listen.jsp")})
	public String redicterListen(){
		return "listen";
	}
	
	/**
	 * 加载推荐的音乐
	 * @return
	 */
	@Action(value="loadListenMusic",results={@Result(name="listenMusic",location="listen/listenMusic.jsp")})
	public String loadListenMusic(){
		List<Music> data=listenService.loadListenMusic(ParamUtil.buildUserId(ServletActionContext.getRequest()));
		request.put(BaseKey.LISTEN_MUSIC_ITEMS, data);
		request.put(BaseKey.LISTEN_MUSIC_ITEM,data.get(0));
		return "listenMusic";
	}
	
	
}
